<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="/admin/header.jsp"></jsp:include>
<div class="main">
	<div class="body container">
		<div class="typecho-page-title">
			<h2>
				管理分类<a href="${options.siteUrl}/admin/category">新增</a>
			</h2>
		</div>
		<div class="row typecho-page-main manage-metas">

			<div class="col-mb-12" role="main">

				<form method="post" name="manage_categories" class="operate-form">
					<div class="typecho-list-operate clearfix">
						<div class="operate">
							<label><i class="sr-only">全选</i><input type="checkbox"
								class="typecho-table-select-all"></label>
							<div class="btn-group btn-drop">
								<button class="btn dropdown-toggle btn-s" type="button">
									<i class="sr-only">操作</i>选中项 <i class="i-caret-down"></i>
								</button>
								<ul class="dropdown-menu">
									<li><a lang="此分类下的所有内容将被删除, 你确认要删除这些分类吗?"
										href="${options.siteUrl }/action/admin?do=deleteCategory">删除</a></li>
									<li class="multiline">
										<button type="button" class="btn merge btn-s"
											rel="${options.siteUrl }/action/admin?do=mergeCategory">合并到</button>
										<select name="merge">
											<c:forEach var="category" items="${categories}">
												<option value="${category['mid']}">${category['name']}</option>
											</c:forEach>
									</select>
									</li>
								</ul>
							</div>
						</div>
						<div class="search" role="search"></div>
					</div>

					<div class="typecho-table-wrap">
						<table class="typecho-list-table">
							<colgroup>
								<col width="20">
								<col width="30%">
								<col width="15%">
								<col width="25%">
								<col width="">
								<col width="10%">
							</colgroup>
							<thead>
								<tr class="nodrag">
									<th></th>
									<th>名称</th>
									<th>缩略名</th>
									<th></th>
									<th>文章数</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td style="padding: 0; height: 0; line-height: 0; border: none"
										colspan="6"></td>
								</tr>
							</tfoot>
							<tbody>
								<c:forEach var="category" items="${categories}">
									<tr id="mid-category-${category['mid'] }" style="cursor: move;">
										<td style="height: 21px;"><input type="checkbox"
											value="${category['mid']  }" name="mid[]"></td>
										<td style="height: 21px;"><a
											href="${options.siteUrl }/admin/category?mid=${category['mid']  }">${category['name']  }</a>
											<a href="${options.siteUrl }/category/${category['slug']  }"
											title="浏览 ${category['name']  }" target="_blank"><i
												class="i-exlink"></i></a></td>
										<td style="height: 21px;">${category['slug']  }</td>
										<td style="height: 21px;">默认</td>
										<td style="height: 21px;"><a
											class="balloon-button left size-10"
											href="${options.siteUrl }/admin/manage-posts?category=${category['mid']  }">${category['mid']  }</a></td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<jsp:include page="/admin/copyright.jsp"></jsp:include>
<jsp:include page="/admin/common-js.jsp"></jsp:include>
<script type="text/javascript">
	(function() {
		$(document)
				.ready(
						function() {
							var table = $('.typecho-list-table')
									.tableDnD(
											{
												onDrop : function() {
													var ids = [];

													$('input[type=checkbox]',
															table)
															.each(
																	function() {
																		ids
																				.push($(
																						this)
																						.val());
																	});

													$
															.post(
																	'http://localhost/typecho/index.php/action/metas-category-edit?do=sort&_=c870a3017fe63ddbcacbeb44aa59d839',
																	$
																			.param({
																				mid : ids
																			}));

													$('tr', table)
															.each(
																	function(i) {
																		if (i % 2) {
																			$(
																					this)
																					.addClass(
																							'even');
																		} else {
																			$(
																					this)
																					.removeClass(
																							'even');
																		}
																	});
												}
											});

							table.tableSelectable({
								checkEl : 'input[type=checkbox]',
								rowEl : 'tr',
								selectAllEl : '.typecho-table-select-all',
								actionEl : '.dropdown-menu a'
							});

							$('.btn-drop').dropdownMenu({
								btnEl : '.dropdown-toggle',
								menuEl : '.dropdown-menu'
							});

							$('.dropdown-menu button.merge').click(
									function() {
										var btn = $(this);
										btn.parents('form').attr('action',
												btn.attr('rel')).submit();
									});

						});
	})();
</script>
<jsp:include page="/admin/footer.jsp"></jsp:include>
